package com.feng.boot.mybatis.mapper;

import com.feng.boot.mybatis.bean.Department;
import org.apache.ibatis.annotations.*;

/**
 * @author Lee
 */
//@Mapper
public interface DepartmentMapper {

    /**
     * 根据 ID 查询 Department
     * @param id
     * @return
     */
    @Select("select * from department d where d.id = #{id}")
    Department getDeptById(Integer id);

    /**
     * 根据 ID 删除 Department
     * @param dId
     * @return
     */
    @Delete("delete from department d where d.id = #{id}")
    int deleteDepartment(Integer dId);;

    /**
     * 插入 Department
     * @param department
     * @return
     */
    @Options(useGeneratedKeys = true,keyProperty = "id")
    @Insert("insert into department(department_name) value (#{departmentName})")
    int insertDepartment(Department department);

    /**
     * 更新 departmentName
     * @param department
     * @return
     */
    @Update("update department d set d.department_name = ${departmentName} where d.id = ${id}")
    int updateSelective(Department department);

}
